<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta content="IE=9" http-equiv="x-ua-compatible">
<head th:include="include :: header"></head>

<style>
	#img{
		list-style-type: none;
		margin: 2px;
		/*height: 118px;*/
		float: left;
	}
	.divImg{
		float: left;
		margin: 2px;
		padding: 2px;
		height:108px;
		width:100px;
		border: 1px solid #dcdcdc;
		cursor: pointer;
	}
	.divImgD{
		float: left;
		margin: 2px;
		padding: 2px;
		height:108px;
		width:100px;
		border: 1px solid red;
		cursor: pointer;
	}


	#img_detail{
		list-style-type: none;
		margin: 2px;
		/*height: 118px;*/
		float: left;
	}
	.divImgDetail{
		float: left;
		margin: 2px;
		padding: 2px;
		height:108px;
		width:100px;
		border: 1px solid #dcdcdc;
		cursor: pointer;
	}

</style>

<body class="gray-bg">

<div class="pull-right">
	<div class="btn-group tool-button">
		<button class="btn btn-primary navbar-btn" type="button" onclick="update()"> 保存</button>
	</div>
</div>

<div class="content-wrap">
	<div class="wrapper" style="min-height:500px;">
		<form class="form-horizontal m-t" id="signupForm">
		<!--<form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate-->
			  <!--action="${base!}/platform/goods/goods/editDo" method="post">-->


			<input type="hidden" name="id" id="id" th:value="${goodsGoods.id}">
			<input type="hidden" name="isSubmit" id="isSubmit" value="0">
			<div class="box-tab tabs-left">
				<ul class="nav nav-tabs">
					<li class="active"><a href="#base" data-toggle="tab">基本信息</a>
					</li>
					<li id="xxcs_tab" class="" style="display: block;"><a href="#xxcs" data-toggle="tab">详细参数</a>
					</li>
					<!--<li class=""><a href="#inf" data-toggle="tab">商品介绍</a>
					</li>-->
				</ul>
				<div class="tab-content text-center">
					<div class="tab-pane fade active in" id="base">
						<div class="row mb10">
							<div class="col-lg-12">
							
								<div class="form-group has-feedback">
									<label for="classId" class="col-sm-2 control-label">商品分类</label>

									<div class="col-sm-8">
										<div class="input-group">
											<input id="classId" type="text" class="form-control" placeholder="请选择商品分类" disabled
												   th:value="${goodsClass.name}"/>

											<span class="input-group-btn">
			                             			<button type="button" class="btn btn-primary" data-toggle="modal"
															data-target="#dialogSelectClass"><i class="ti-plus"></i>选择
                                                    </button>
			                             		</span>

										</div>
										<input type="hidden" name="classId" th:value="${goodsClass.id}">
									</div>
								</div>
								
								<div class="form-group">
									<label for="typeId" class="col-sm-2 control-label">商品类型</label>

									<div class="col-sm-8">
										<select id="typeId" name="typeId" class="form-control">
											<!-- <option value="">请选择</option> -->
											<!--<%for(o in typeList){%>-->
											<!--<option value="${o.id!}" <%if(obj.typeId==o.id){%>selected<%}%>>${o.name!}</option>-->
											<option th:each="tList : ${typeList}"  th:value="${tList.id}"  th:selected="${tList.id}==${goodsGoods.typeId}?selected:no"> <span th:text="${tList.name}" ></span></option>
											<!--<%}%>-->
										</select>
									</div>
								</div>
								<!--<div class="form-group" >
									<label for="brandId" class="col-sm-2 control-label">品牌</label>

									<div class="col-sm-8">
										<select id="brandId" name="brandId" class="form-control">
											&lt;!&ndash; <option value="">请选择</option> &ndash;&gt;
											&lt;!&ndash;<%for(o in typeList){%>&ndash;&gt;
											&lt;!&ndash;<option value="${o.id!}" <%if(obj.typeId==o.id){%>selected<%}%>>${o.name!}</option>&ndash;&gt;
											<option th:each="bList : ${brandList}"  th:value="${bList.id}"  th:selected="${bList.id}==${goodsGoods.brandId}?selected:no"> <span th:text="${bList.name}" ></span></option>
											&lt;!&ndash;<%}%>&ndash;&gt;
										</select>
									</div>
								</div>-->
								<!-- <div class="form-group">
									<label for="warehouseId" class="col-sm-2 control-label">货仓</label>

									<div class="col-sm-8">
										<select id="warehouseId" name="warehouseId" class="form-control">
											<option value="">请选择</option>
											<%for(o in typeList){%>
											<option value="${o.id!}" <%if(obj.typeId==o.id){%>selected<%}%>>${o.name!}</option>
											<option th:each="wList : ${wareList}"  th:value="${wList.id}"  th:selected="${wList.id}==${goodsGoods.warehouseId}?selected:no"> <span th:text="${wList.name}" ></span></option>
											<%}%>
										</select>
									</div>
								</div> -->
								
								<div class="form-group">
									<label for="name" class="col-sm-2 control-label"><span style="color: red">*</span>商品名称</label>

									<div class="col-sm-8">
										<input type="text" id="name" class="form-control" name="name" data-parsley-required="true"
											   placeholder="商品名称" th:value="${goodsGoods.name}"  data-parsley-maxlength="150">
									</div>
								</div>
								<div class="form-group">
									<label for="title" class="col-sm-2 control-label">商品标题</label>

									<div class="col-sm-8">
										<input type="text" id="title" class="form-control" name="title"
											   placeholder="商品标题" th:value="${goodsGoods.title}"  data-parsley-maxlength="150">
									</div>
								</div>
								<!--<div class="form-group">
									<label for="copywriting" class="col-sm-2 control-label"><span style="color: red">*</span>商品文案</label>

									<div class="col-sm-8">
											<textarea type="text" style="height: 120px" id="copywriting" class="form-control" name="copywriting"
													  placeholder="商品文案" th:text="${goodsGoods.copywriting}"  maxlength="300" required></textarea>
									</div>
								</div>-->
								<!-- <div class="form-group">
									<label for="brandId" class="col-sm-2 control-label">品牌</label>

									<div class="col-sm-8">
										<select id="brandId" name="brandId" class="form-control">
											<%for(o in brandList){%>
											<option value="${o.id!}" <%if(obj.brandId==o.id){%>selected<%}%>>${o.name!}</option>
											<option th:each="bList : ${brandList}"  th:value="${bList.id}" th:selected="${bList.id}==${goodsGoods.brandId}?selected:no"><span th:text="${bList.name}" ></span></option>
											<%}%>
										</select>
									</div>
								</div> -->

								<div class="form-group">
									<label for="file_upload" class="col-sm-2 control-label">商品轮播图</label>

									<div class="col-sm-8">
										<div id="queue"></div>
										<div >
											<input id="file_upload" name="file_upload" type="file" multiple="true">

										</div>
										<div id="img">

										</div>
									</div>
								</div>

								<div class="form-group">
									<label for="file_upload_detail" class="col-sm-2 control-label">商品详情图片</label>

									<div class="col-sm-8">
										<div id="queue_detail"></div>
										<div >
											<input id="file_upload_detail" name="file_upload_detail" type="file" multiple="true">

										</div>
										<div id="img_detail">

										</div>
									</div>
								</div>


								<div id="sp_new" th:style="${goodsGoods.hasSpec}==1? 'display:block' : 'display:none'" >
									<!--<%if(obj.hasSpec){%>-->

									<div class="form-group" id="gg_new">
										<label for="gg_new" class="col-sm-2 control-label">规格</label>
										<div class="col-sm-8">
											<button id="specEditBtn" class="btn btn-primary" style="float: left;" type="button">编辑规格</button>
											<div style="float: left;text-align: left;">
												已设置<span th:text="${productNum}"></span>个规格货品 [
												<span th:each="pList : ${productList}" th:text="${pList.spec}"></span>
												]</div>
										</div>
									</div>
									<!--<%}%>-->
								</div>
								<div id="sp" th:style="${goodsGoods.hasSpec}==0? 'display:block' : 'display:none'">

									<div class="form-group">
										<label for="price" class="col-sm-2 control-label">市场价格</label>

										<div class="col-sm-8">
											<input type="text" id="priceMarket" class="form-control" th:value="${goodsGoods.goodsProduct.priceMarket}" style="width: 200px;" name="priceMarket" placeholder="市场价格(0.00)" onkeyup=checkNum(this)>
										</div>
									</div>

									 <div class="form-group">
										<label for="price" class="col-sm-2 control-label">价格</label>

										<div class="col-sm-8">
											<input type="text" id="price" class="form-control" th:value="${goodsGoods.goodsProduct.price}" style="width: 200px;" name="price" placeholder="普通用户价格(0.00)" onkeyup=checkNum(this)>
										</div>
									</div>

									 <div class="form-group">
										<label for="priceC" class="col-sm-2 control-label"><span style="color: red">*</span>团长价格</label>
										<div class="col-sm-8">
											<input type="text" id="priceC" class="form-control" th:value="${goodsGoods.goodsProduct.priceC}" style="width: 200px;" name="priceC" placeholder="总监价格(0.00)"  required onkeyup=checkNum(this)>
										</div>
									</div>
									<div class="form-group">
										<label for="priceZ" class="col-sm-2 control-label"><span style="color: red">*</span>核心价格</label>

										<div class="col-sm-8">
											<input type="text" id="priceZ" class="form-control" th:value="${goodsGoods.goodsProduct.priceZ}" style="width: 200px;" name="priceZ" placeholder="总代价格(0.00)"  required onkeyup=checkNum(this)>

										</div>
									</div>
									<div class="form-group">
										<label for="priceG" class="col-sm-2 control-label"><span style="color: red">*</span>合伙人价格</label>

										<div class="col-sm-8">
											<input type="text" id="priceG" class="form-control" th:value="${goodsGoods.goodsProduct.priceG}" style="width: 200px;" name="priceG" placeholder="店长价格(0.00)"  required onkeyup=checkNum(this)>

										</div>
									</div>
									<div class="form-group">
										<label for="rebateOne" class="col-sm-2 control-label">运险费</label>

										<div class="col-sm-8">
											<input type="text" id="rebateOne" th:value="${goodsGoods.goodsProduct.rebateOne}" class="form-control" style="width: 200px;" name="rebateOne" placeholder="运险费(0.00)" onkeyup=checkNum(this)>

										</div>
									</div>
									<div class="form-group">
										<label for="rebateTwo" class="col-sm-2 control-label">接单价</label>

										<div class="col-sm-8">
											<input type="text" id="rebateTwo" th:value="${goodsGoods.goodsProduct.rebateTwo}" class="form-control" style="width: 200px;" name="rebateTwo" placeholder="接单价(0.00)" onkeyup=checkNum(this)>

										</div>
									</div>
 								<!--<div class="form-group" id="postSizeDiv" >
									<label for="disabled" class="col-sm-2 control-label">运费方式</label>

									<div id="postSize" class="col-sm-8" style="float: left;text-align: left">
										<input type="radio" th:field="*{goodsGoods.postSize}" name="postSize" value="0" >通用
										<input type="radio" th:field="*{goodsGoods.postSize}" name="postSize" value="1" checked>模板
										<input type="radio" th:field="*{goodsGoods.postSize}" name="postSize" value="2" checked>包邮

									</div>
								</div>
									<div class="form-group" id="postFeeDiv">
										<label for="postFee" class="col-sm-2 control-label"><span style="color: red">*</span>通用运费</label>

										<div class="col-sm-8">
											<input type="text" id="postFee" th:value="${goodsGoods.goodsProduct.postFee}" class="form-control" style="width: 300px;" name="postFee" placeholder="运费(0.00)" onkeyup=checkNum(this)>

										</div>
									</div>-->
									<div class="form-group">
										<label for="weight" class="col-sm-2 control-label">重量</label>

										<div class="col-sm-8">
											<input type="text" id="weight" th:value="${goodsGoods.goodsProduct.weight}" class="form-control" style="width: 200px;" name="weight" placeholder="克(g)">

										</div>
									</div>
									<div class="form-group">
										<label for="sku" class="col-sm-2 control-label">SKU货号</label>

										<div class="col-sm-8">
											<input type="text" id="sku" th:value="${goodsGoods.goodsProduct.sku}" class="form-control" name="sku" placeholder="货号(不填则自动生成)">

										</div>
									</div>
									<div class="form-group">
										<label for="stock" class="col-sm-2 control-label">库存</label>

										<div class="col-sm-8">
											<input type="text" id="stock" th:value="${goodsGoods.goodsProduct.stock}" class="form-control" style="width: 200px;" name="stock" placeholder="库存">

										</div>
									</div>
				 					<div class="form-group">
										<label for="buyMin" class="col-sm-2 control-label">最小购买量</label>

										<div class="col-sm-8">
											<input type="text" id="buyMin" class="form-control" style="width: 200px;" th:value="${goodsGoods.goodsProduct.buyMin}" name="buyMin" placeholder="默认为1">

										</div>
									</div>
									<div class="form-group">
										<label for="buyMax" class="col-sm-2 control-label">最大购买量</label>

										<div class="col-sm-8">
											<input type="text" id="buyMax" class="form-control" style="width: 200px;" th:value="${goodsGoods.goodsProduct.buyMax}"  name="buyMax" placeholder="默认为100">
										</div>
									</div>

									<div class="form-group" id="gg" style="display: none">
										<label for="gg" class="col-sm-2 control-label">规格</label>

										<div class="col-sm-8">
											<button id="specBtn" class="btn btn-primary" style="float: left;" type="button">开启规格</button>
										</div>
									</div>
								</div>

								
								<!-- <div class="form-group">
									<label for="allNumber" class="col-sm-2 control-label">商品最大购买量</label>

									<div class="col-sm-8">
										<input type="text" id="allNumber" class="form-control" style="width: 200px;" th:value="${goodsGoods.allNumber}"  name="allNumber" placeholder="默认为100">
									</div>
								</div> -->
								<div class="form-group" id="postSizeDiv" >
									<label for="disabled" class="col-sm-2 control-label">运费方式</label>

									<div id="postSize" class="col-sm-8" style="float: left;text-align: left">
										<input type="radio" th:field="*{goodsGoods.postSize}" name="postSize" value="0" >通用
										<input type="radio" th:field="*{goodsGoods.postSize}" name="postSize" value="1" checked>模板
										<input type="radio" th:field="*{goodsGoods.postSize}" name="postSize" value="2" checked>包邮

									</div>
								</div>
								<div class="form-group" id="postFeeDiv">
									<label for="postFee" class="col-sm-2 control-label"><span style="color: red">*</span>通用运费</label>

									<div class="col-sm-8">
										<input type="text" id="postFee" th:value="${goodsGoods.goodsProduct.postFee}" class="form-control" style="width: 300px;" name="postFee" placeholder="运费(0.00)" onkeyup=checkNum(this)>

									</div>
								</div>
								<div class="form-group">
									<label for="unit" class="col-sm-2 control-label">计量单位</label>

									<div class="col-sm-8">
										<input id="unit" type="text" th:value="${goodsGoods.goodsProduct.unit}" class="form-control" style="width: 200px;" name="unit" placeholder="计量单位">

									</div>
								</div>
								<div class="form-group">
									<label for="numSale" class="col-sm-2 control-label">总销量</label>

									<div class="col-sm-8">
										<input id="numSale" type="text" th:value="${goodsGoods.numSale}" class="form-control" style="width: 200px;" name="numSale" placeholder="总销量">

									</div>
								</div>
								
								
								<input type="hidden" name="message" id="message" value="1">
									<!-- <input type="hidden" name="isvip" id="isvip" value="0"> -->
								<!-- <div class="form-group" id='divMessage'>
									<label for="disabled" class="col-sm-2 control-label">是否合单</label>

									<div id="message" class="col-sm-8" style="float: left;text-align: left">
										<input type="radio" th:field="*{goodsGoods.message}" name="disabled" value="0" >留言
										<input type="radio" th:field="*{goodsGoods.message}" name="disabled" value="1" checked>不留言

									</div>
								</div>-->



								<!-- <div class="form-group">
									<label class="col-sm-2 control-label">会员等级限制：</label>
									<div class="col-sm-8" style="float: left;text-align: left">
										<input type="checkbox" th:checked="${#strings.contains(goodsGoods.vipLevel,'0')}" name="vipLevel0" value="0" />
										游客
										<input type="checkbox" th:checked="${#strings.contains(goodsGoods.vipLevel,'1')}" name="vipLevel0" value="1" />
										初级会员
										<input type="checkbox" th:checked="${#strings.contains(goodsGoods.vipLevel,'2')}" name="vipLevel0" value="2" />
										中级会员
										<input type="checkbox" th:checked="${#strings.contains(goodsGoods.vipLevel,'3')}" name="vipLevel0" value="3" />
										高级会员
										<input type="checkbox" th:checked="${#strings.contains(goodsGoods.vipLevel,'4')}" name="vipLevel0" value="4" />
										初级分销
										<input type="checkbox" th:checked="${#strings.contains(goodsGoods.vipLevel,'5')}" name="vipLevel0" value="5" />
										高级分销
									</div>
								</div> -->
								<!--<div class="form-group" id='divRecommend'>
									<label for="disabled" class="col-sm-2 control-label">是否推荐</label>

									<div id="recommend" class="col-sm-8" style="float: left;text-align: left">
										<input type="radio" th:field="*{goodsGoods.recommend}" name="disabled" value="1" >推荐
										<input type="radio" th:field="*{goodsGoods.recommend}" name="disabled" value="0" checked>不推荐

									</div>
								</div>-->

								<div class="form-group">
									<label for="group" class="col-sm-2 control-label">商品类别</label>

									<div id="group" class="col-sm-8" style="float: left;text-align: left">
										<input type="radio" th:field="*{goodsGoods.category}" name="category" value="0"  checked>普通
										<input type="radio" th:field="*{goodsGoods.category}" name="category" value="1"  checked>今日主推
										<input type="radio" th:field="*{goodsGoods.category}" name="category" value="2"  checked>秒杀
										<input type="radio" th:field="*{goodsGoods.category}" name="category" value="3"  checked>福利专区

									</div>
								</div>
								<!-- style="display: none" -->
								<div id='spikeStrDiv' class="form-group" >
									<label class="col-sm-2 control-label">开始时间：</label>
									<div class="col-sm-8">
										<input id="spikeStr" name="spikeStr" th:value="${#dates.format(goodsGoods.spikeStr, 'yyyy-MM-dd HH:mm:ss')}" pattern="yyyy-MM-dd HH:mm:ss" class="form-control" type="text" style="width: 200px;" >
									</div>
								</div>
								<!-- style="display: none" -->
								<div id='spikeEndDiv' class="form-group" >
									<label class="col-sm-2 control-label">结束时间：</label>
									<div class="col-sm-8">
										<input id="spikeEnd" name="spikeEnd" th:value="${#dates.format(goodsGoods.spikeEnd, 'yyyy-MM-dd HH:mm:ss')}" pattern="yyyy-MM-dd HH:mm:ss" class="form-control" type="text" style="width: 200px;" >
									</div>
								</div>

								<div class="form-group">
									<label class="col-sm-2 control-label">直播视频：</label>
									<div class="col-sm-1">
										<div id="live_upload">
										</div>
										<div id="logo_live" style="padding: 5px;">
											<embed th:src="${goodsGoods.live}" style='height: 60px;width: 60px'>
											<i class="fa fa-close" onclick="$('#live').val('');$('#logo_live').html('');"></i>

										</div>
										<input type="hidden" id="live" name="live" th:value="${goodsGoods.live}" >
									</div>
								</div>

								<div class="form-group">
									<label class="col-sm-2 control-label">是否合单：</label>
									<div class="col-sm-8" style="float: left;text-align: left">
										<input type="radio" th:field="*{goodsGoods.isvip}" name="isvip" value="0" />
										不参与
										<input type="radio" th:field="*{goodsGoods.isvip}" name="isvip" value="1" />
										参与
									</div>
								</div>
								<div class="form-group">
									<label for="disabled" class="col-sm-2 control-label">是否上架</label>

									<div id="disabled" class="col-sm-8" style="float: left;text-align: left">
										<input type="radio" th:field="*{goodsGoods.disabled}" name="disabled" value="0" checked>上架
										<input type="radio" th:field="*{goodsGoods.disabled}" name="disabled" value="1">下架

									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="tab-pane fade" id="xxcs">
						<!--<%for(paramg in typeParamgList){%>-->
						<div class="form-group" th:each="paramg : ${typeParamgList}">
							<label class="col-sm-3 control-label" ><span th:text="${paramg.name}"></span></label>
							<!--<%for(p in paramg.params){%>-->
							<div class="col-sm-12" th:each="p : ${paramg.params}" style="padding-bottom:5px;">
								<div class="col-sm-10 input-group">
									<span class="input-group-btn">
									<button class="btn" style="width:120px;" type="button" th:text="${p.name}"></button>
									</span>
										<input type="text" class="form-control" th:placeholder="${p.name}">
								</div>
							</div>
							<!--<%}%>-->
						</div>
						<!--<%}%>-->

					</div>
					<div class="tab-pane fade" id="inf">
						<div class="row mb10">
							<div class="col-lg-12" style="text-align:left">
								<textarea id="note" name="note" style="width:100%;height:200px;" th:text="${goodsGoods.note}"></textarea>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col-lg-3"></div>
			<input id="hasSpec" name="hasSpec" type="hidden" th:value="${goodsGoods.hasSpec}">
			<input id="products" name="products" type="hidden" value="">
			<input id="images" name="images" type="hidden" value="">
			<input id="vipLevel" name="vipLevel" type="hidden" value="0">
			<input id="imagesDetail" name="imagesDetail" type="hidden" value="">
			<input id="spec_values" name="spec_values" type="hidden" value="[]">
			<input id="param_values" name="param_values" type="hidden" value="[]">
		</form>

	</div>
</div>
<!-- 选择上级 -->
<div id="dialogSelectClass" class="modal fade bs-modal-sm" tabindex="-1" role="dialog" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h4 class="modal-title">选择分类</h4>
			</div>
			<div class="modal-body">
				<div class="row">
					<div class="col-xs-12">
						<div id="jsTreeClass" class="demo"></div>
					</div>
				</div>
			</div>
			<div class="modal-footer">
				<div class="pull-left">
					<button type="button" class="btn btn-success" data-dismiss="modal" onclick="selectFirstClass()">不限分类</button>
				</div>
				<button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
				<button type="button" class="btn btn-primary" onclick="selectClass()">确认选择</button>
			</div>
		</div>
	</div>
</div>

<div id="specHtml">

	<div id="dialogSpec" class="modal fade" tabindex="-2" role="dialog" aria-hidden="true" style="display: none;">
		<div class="modal-dialog" style="width: 1000px;">
			<div class="modal-content" style="width: 1000px;">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<h4 class="modal-title">商品规格</h4>
				</div>
				<div class="modal-body" style="min-height: 300px;">
					<div class="row">
						<div class="col-xs-12" style="float: left">
							<div class="spec" th:each="spList : ${specList}" style="float: left;padding-right: 10px;padding-left: 10px" th:attr="data-spec-name=${spList.spec.name},data-spec-type=${spList.spec.type},data-spec-id=${spList.spec.id}"   >
								<span class="h5 mb10" style="float: left"><input class="specChkAll" type="checkbox"><strong th:text="${spList.spec.name}"></strong></span>
								<div style="float: left;padding-left: 20px;">

									<div class="vl" th:each="sVList : ${spList.specValList}" >
										<input th:id="${sVList.specValueId}" type="checkbox" th:value="${sVList.specValueId}"
											   th:title="${sVList.specValText}"><span th:text="${sVList.specValText}"></span>
									</div>

								</div>
							</div>
						</div>
						<div class="col-xs-12" style="padding-top: 5px;height: 45px;">
							<button id="doProduct" type="button" class="btn btn-primary btn-sm">生成所有货品</button>
						</div>
						<div style="width: 100%;text-align: center;margin-top: 10px;">
							<table id="plist" class="table table-bordered table-striped table-condensed" style="width: 95%;margin: 20px;">
								<thead>
								<tr>
									<th>规格值</th>
									<th>货号</th>
									<th class="numeric">上架</th>
									<th class="numeric">库存</th>
									<th class="numeric">最小购买</th>
									<th class="numeric">最大购买</th>
									<th class="numeric">市场价</th>
									<th class="numeric">用户价格</th>
									<th class="numeric">团长价</th>
									<th class="numeric">核心价</th>
									<th class="numeric">合伙人价</th>
									
									<!-- <th class="numeric">初级分销自反</th>
									<th class="numeric">高级分销自反</th> -->
									<!--<th class="numeric">运费</th>-->
									<th class="numeric">运险费</th>
									<th class="numeric">接单价</th>
									<th class="numeric">重量(g)</th>
									<th class="numeric">默认货品</th>
									<th class="numeric">操作</th>
								</tr>
								</thead>
								<tbody>

								<tr th:each="gproduct:${productList}">
									<td><span th:text="${gproduct.spec}"></span><input name="productId" type="hidden" th:value="${gproduct.id}"></td>
									<td><input name="sku" type="text" class="form-control" th:value="${gproduct.sku}" style="height: 22px;width: 80px;padding: 0 2px;"></td>
									<td><input name="up" type="checkbox" checked ></td>
									<td><input name="stock" type="text" th:value="${gproduct.stock}" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>
									<td><input name="buyMin" type="text" th:value="${gproduct.buyMin}" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>
									<td><input name="buyMax" type="text" th:value="${gproduct.buyMax}" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>
									<td style="text-align: left;width: 150px;">
										<div style="float: left"><input name="priceMarket" type="text" th:value="${gproduct.priceMarket}" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></div>
									</td>
									<td style="text-align: left;width: 150px;">
										<div style="float: left"><input name="price" type="text" th:value="${gproduct.price}" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></div>
									</td>
									<td><input name="priceC" th:value="${gproduct.priceC}"  type="text" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>
									<td><input name="priceZ" th:value="${gproduct.priceZ}"  type="text" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>
									<td><input name="priceG" th:value="${gproduct.priceG}"  type="text" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>
									<!--<td><input name="postFee" th:value="${gproduct.postFee}"  type="text" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>-->
									 <td><input name="rebateOne" th:value="${gproduct.rebateOne}"  type="text" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>
									<td><input name="rebateTwo" th:value="${gproduct.rebateTwo}"  type="text" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>
									<!--<td style="display: none"><input name="priceCost" value="" type="text" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>-->
									<td><input name="weight" th:value="${gproduct.weight}"  type="text" class="form-control" style="height: 22px;width: 60px;padding: 0 2px;"></td>
									<td><input name="isDefault" type="checkbox" th:checked="${gproduct.isDefault==1}?checked:no"></td>
									<td><a class="delSpec" href="javascript:;" style="color: #428bca">删除</a></td></tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
					<button id="dialogSpecOK" type="button" class="btn btn-primary" data-loading-text="保存...">保 存</button>
				</div>
			</div>
		</div>
	</div>
	<div id="dialogImg" class="modal fade" style="padding-top: 20px; display: none;" tabindex="-2" role="dialog" aria-hidden="true">
		<div class="modal-dialog" style="width: 650px;">
			<div class="modal-content" style="width: 650px;">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<h4 class="modal-title">选择商品图片</h4>
				</div>
				<div class="modal-body">
					<div class="row" id="dialogImg_imgs">
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
					<button id="specImgDelBtn" type="button" class="btn btn-danger" data-loading-text="删除...">删 除</button>

				</div>
			</div>
		</div>
	</div>

</div>

	<div th:include="include::footer"></div>
<link rel="stylesheet" href="/js/plugins/uploadifive/uploadifive.css">
<script src="/js/plugins/uploadifive/jquery.uploadifive.min.js"></script>
<script src="/js/jquery.sortable.js"></script>
<script src="/js/plugins/sorttable/Sortable.min.js"></script>
<script src="/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/js/plugins/validate/messages_zh.min.js"></script>
<script src="/js/appjs/wx/goodsSpike/adddate.js"></script>
<script th:inline="javascript">
    sessionStorage.setItem("products",JSON.stringify([[${productList}]]));
    $(function(){
        //初始化商品参数
        var param=JSON.parse([[${goodsGoods.param}]]);
        $.each(param,function(i,o){
            var name= o.name;
            $.each(o.value,function(j,k){
                $("#xxcs").find(".form-group").each(function(r,t){
                    var self=$(this);
                    if($(this).find(".control-label").text()== o.name){
                        self.find(".input-group").each(function(n,m){
                            var obj=$(this);
                            if(obj.find("button").html()== k.name){
                                obj.find("input").val(k.value);
                            }
                        });
                    }
                });
            });
        });
    });
</script>
<script language="JavaScript" th:inline="none">
    function specSelImg(id,url){
        $("#s_img"+id).html("<img class='specImg' src='"+url+"' style='height: 30px;width: 30px;'>");
        $("#dialogImg").modal("hide");
    }
    function specDelImg(id){
        $("#s_img"+id).html("");
    }
    function selImg(id){
        var imgs=getImg();
        $("#dialogImg_imgs").html("");
        $.each(imgs,function(i,o){
            var str="<div style='margin:2px;float:left;text-align: center;border: 1px solid #dcdcdc;cursor: pointer;' onclick=\"specSelImg('"+id+"','"+o.url+"')\" >" +
                "<img src='" + o.url + "' style='width:100px;height: 80px;margin-bottom: 1px;'></div>";
            $("#dialogImg_imgs").append(str);
            $("#specImgDelBtn").unbind("click").on("click",function(){
                specDelImg(id);
                $("#dialogImg").modal("hide");
            });
        });
        $("#dialogImg").modal("show");
    }
    function getSpec(){
        var specs=[];
        $("#dialogSpec").find("div .spec").each(function(){
            var self=$(this);
            var spec={};
            var spec_values=[];
            spec.spec_name=$(this).attr("data-spec-name");
            spec.spec_type=$(this).attr("data-spec-type");
            spec.spec_id=$(this).attr("data-spec-id");

            self.find("div .vl").each(function(){
                var v={};
                v.spec_name=spec.spec_name;
                v.spec_type=spec.spec_type;
                v.spec_id=spec.spec_id;
                var chk=false;
                $(this).find("img[class='specImg']").each(function(){
                    v.spec_value_imgurl=$(this).attr("src");
                });
                $(this).find("input[type=checkbox]").each(function(){
                    v.spec_value_id=$(this).val();
                    v.spec_value_name=$(this).attr("title");
                    chk=$(this).prop("checked");
                });
                if(chk){
                    spec_values.push(v);
                    spec.spec_values=spec_values;
                }
            });
            if(spec_values.length>0){
                specs.push(spec);
            }

        });
        return specs;
    }
    function getProducts(specs) {
        if (!specs || specs.length == 0) {
            return [];
        } else {
            return joinSpec([[]], specs, 0, specs.length-1);
        }
        function joinSpec(prevProducts, specs, i, max) {
            var currentProducts = [], currentProduct, currentSpecs = specs[i];
            if ( i > max ) {
                return prevProducts;
            }
            $.each(prevProducts,function(i,prevProduct) {
                $.each(currentSpecs,function(j,spec) {
                    currentProduct = prevProduct.slice(0);
                    currentProduct.push(spec);
                    currentProducts.push(currentProduct);
                });
            });
            return joinSpec(currentProducts, specs, ++i, max);
        }
    }
    </script>
    <script language="JavaScript" th:inline="javascript">
    $(document).ready(function () {
        //初始化商品设置的规格选项及规格图片
        var spec=JSON.parse([[${goodsGoods.spec}]]);
        $.each(spec,function (i,ss) {
            $.each(ss,function (j,s) {
                if(s.spec_value_imgurl){
                    $("#s_img"+s.spec_value_id).html('<img class="specImg" src="'+s.spec_value_imgurl+'" style="height: 30px;width: 30px;">');
                }
                $("#s"+s.spec_value_id).prop('checked',true);

            });
        });
        $(".specChkAll").on("click",function(){
            if($(this).prop("checked")){
                $(this).parent().parent().find("input[type=checkbox]").each(function(){
                    $(this).prop("checked",true);
                });
            }else {
                $(this).parent().parent().find("input[type=checkbox]").each(function(){
                    $(this).prop("checked",false);
                });
            }
        });
        $("#doProduct").on("click",function(){
            var specs=getSpec();
            var product_name=[];
            var spec_values=[];
            var size=1;
            $.each(specs,function(i,s){
                size=size * s.spec_values.length;
                var t=[];
                $.each(s.spec_values,function(j,o){
                    t.push(o);
                });
                spec_values.push(t);
            });
//      console.log('spec_values::'+JSON.stringify(spec_values));
            $.each(getProducts(spec_values),function(i,v){
                var n="";
                $.each(v,function(j,s){
                    n=n+ s.spec_name+":"+ s.spec_value_name;
                    if(j< v.length-1)n+="*";
                });
                product_name.push(n);
            });
            if(spec_values.length<1){
                Toast.warning("至少选择一种规格");
                return false;
            }
            //console.log("product_name::"+JSON.stringify(product_name));
            $("#plist tbody").html("");
            var i=0;
            var sku=$("#sku").val();
            var buyMin=$("#buyMin").val();
            var buyMax=$("#buyMax").val();
            var stock=$("#stock").val();
			var priceMarket=$("#priceMarket").val();
            var price=$("#price").val();
			 var priceC=$("#priceC").val();
			var priceZ=$("#priceZ").val();
			var priceG=$("#priceG").val(); 
             /*var postFee=$("#postFee").val();*/
			 var rebateOne=$("#rebateOne").val();
			var rebateTwo=$("#rebateTwo").val();
            /* var priceCost=$("#priceCost").val(); */
            var weight=$("#weight").val();
            $.each(product_name,function(i,name){
                i++;
                var str="<tr>";
                var bn="";
                if(sku!=""){
                    if(sku.indexOf("-")>0){
                        sku=sku.substring(0,sku.indexOf("-"));
                    }
                    bn=sku+"-"+i;
                }
                str+="<td>"+name+"<input name='productId' type='hidden'></td>";
                str+="<td><input name='sku' type='text' class='form-control'  value='"+bn+"' style='height: 22px;width: 80px;padding: 0 2px;'></td>";
                str+="<td><input name='up' type='checkbox' checked></td>";
                str+="<td><input name='stock' type='text' value='"+stock+"' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>";
                str+="<td><input name='buyMin' type='text' value='"+buyMin+"' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>";
                str+="<td><input name='buyMax' type='text' value='"+buyMax+"' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>";
                str+="<td style='text-align: left;width: 150px;'><div style='float: left'><input name='priceMarket' type='text' value='"+priceMarket+"'  class='form-control'  style='height: 22px;width: 60px;padding: 0 2px; ' ></div></td>";
                str+="<td style='text-align: left;width: 150px;'><div style='float: left'><input name='price' type='text' value='"+price+"'  class='form-control'  style='height: 22px;width: 60px;padding: 0 2px; ' ></div></td>";
				 str+="<td><input name='priceC' value='"+priceC+"' type='text' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>";
				str+="<td><input name='priceZ' value='"+priceZ+"' type='text' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>";
				str+="<td><input name='priceG' value='"+priceG+"' type='text' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>"; 
				/*str+="<td><input name='postFee' value='"+postFee+"' type='text' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>";*/
				 str+="<td><input name='rebateOne' value='"+rebateOne+"' type='text' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>";
				 str+="<td><input name='rebateTwo' value='"+rebateTwo+"' type='text' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>";
                /* str+="<td style='display: none'><input name='priceCost' value='"+priceCost+"' type='text' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>"; */
                str+="<td><input name='weight' value='"+weight+"' type='text' class='form-control' style='height: 22px;width: 60px;padding: 0 2px;'></td>";
                str+="<td><input name='isDefault' type='checkbox'></td>";
                str+="<td><a class='delSpec' href='javascript:;' style='color: #428bca'>删除</a></td>";
                $("#plist tbody").append(str);
            });
            $("#plist .delSpec").on("click",function(){
                $(this).parent().parent().remove();
            });
            $("#plist .member").on("click",function(){
                var self=$(this).parent().find("input[type=hidden]");
                var lvprice=self.val();
                if(lvprice!=""&&lvprice!="[]"){
                    var lvp=JSON.parse(lvprice);
                    $.each(lvp,function(i,lv){
                        var j=0;
                        $("#dialogLvSpec").find("input[type=text]").each(function(){
                            if(i==j)$(this).val(lv.lvPrice);
                            j++;
                        });
                    });
                }else {
                    $("#dialogLvSpec").find("input[type=text]").each(function(){
                        $(this).val("");
                    });
                }
                $("#dialogLvSpec button[type=button]").unbind("click").on("click",function(){
                    var lv=[];
                    $("#dialogLvSpec").find(".lvpricecss").each(function(){
                        var id=$(this).attr("data-lv-id");
                        var price=$(this).find("input[type=text]").val();
                        if(price!="")
                            lv.push({'lvId':id,'lvPrice':price});
                    });
                    self.val(JSON.stringify(lv));
                });
                $("#dialogLvSpec").modal("show");
            });
        });
        // $("#dialogSpecOK").on("click",function(){

                var specs=getSpec();
                var spec_values=[];
                var size=1;
                $.each(specs,function(i,s){
                    size=size * s.spec_values.length;
                    var t=[];
                    $.each(s.spec_values,function(j,o){
                        t.push(o);
                    });
                    spec_values.push(t);
                });
                $("#spec_values").val(JSON.stringify(spec_values));
                var specs=[];
                var specs_name="";
                $("#plist tbody").find("tr").each(function(){
                    var self=$(this);
                    var spec=self.find("td:first").text();
                    specs_name+=spec+"|";
                    var productId=self.find("input[name='productId']").val();
                    var sku=self.find("input[name='sku']").val();
                    var disabled=self.find("input[name='up']").prop("checked")==false;
                    var stock=self.find("input[name='stock']").val();
                    var buyMin=self.find("input[name='buyMin']").val();
                    var buyMax=self.find("input[name='buyMax']").val();
                    var priceMarket=self.find("input[name='priceMarket']").val();
                    var price=self.find("input[name='price']").val();
					var priceC=self.find("input[name='priceC']").val();
					var priceZ=self.find("input[name='priceZ']").val();
					var priceG=self.find("input[name='priceG']").val(); 
                    /* var postFee=self.find("input[name='postFee']").val();*/
					 var rebateOne=self.find("input[name='rebateOne']").val();
					var rebateTwo=self.find("input[name='rebateTwo']").val();
                    var weight=self.find("input[name='weight']").val();
                    var isDefault=self.find("input[name='isDefault']").prop("checked")==true;
                    specs.push({'productId':productId,'spec':spec,'sku':sku,'disabled':disabled,'stock':stock,'buyMin':buyMin,'buyMax':buyMax,'priceMarket':priceMarket,'price':price, 'priceC':priceC,
						'priceZ':priceZ, 'priceG':priceG, /*'postFee':postFee,*/ 'rebateOne':rebateOne,'rebateTwo':rebateTwo, 'weight':weight,'isDefault':isDefault});
                });
                // $("#hasSpec").val("1");
                $("#products").val(JSON.stringify(specs));


        // });
    });
    $("#specEditBtn").on("click",function(){

        layer.full(layer.open({
            type:2,
            title:"编辑规格",
            // area : [ '800px' ],
            maxmin:true,
            content:"/wx/goodsGoods/spec?id="+$("#typeId").val()+"&sku="+$("#sku").val()+"&priceMarket="+$("#priceMarket").val()+"&price="+$("#price").val()
			 +"&priceC="+$("#priceC").val()+"&priceZ="+$("#priceZ").val()+"&priceG="+$("#priceG").val() 
			/* +"&postFee="+$("#postFee").val()*/+"&rebateOne="+$("#rebateOne").val()+"&rebateTwo="+$("#rebateTwo").val()
			+"&weight="+$("#weight").val()
			+"&stock="+$("#stock").val()+"&type=1"
        }));
    });
</script>
	<script type="text/javascript" src="/js/appjs/wx/goodsGoods/edit.js">
	</script>

	<script language="JavaScript" th:inline="javascript">


        var imgNum=0;
        var strImg ='';
        if([[${goodsGoods.banners}]]!=undefined && [[${goodsGoods.banners}]]!=[]) {
             var banners =[[${goodsGoods.banners}]];
            var i = 0;
            for (o in banners) {
                i++;
                imgNum++;
                var c = "divImg";
                if (banners[o].imgurl == [[${goodsGoods.imgurl}]]) {
                    c = "divImgD";
                }
                strImg  += '<div id="imgId'+imgNum+'" class="'+c+'">' +
                    '<img  onclick="setImg(\'imgId' + imgNum  +'\')" src="'+banners[o].imgurl+'" style="width:100px;height: 80px;margin-bottom: 1px;"><br>' +
                    '<i style="float: right;padding-top: 4px;" class="fa fa-close" onclick="delImg(\'imgId' + imgNum  +'\')"></i></div>';

            }
        }
        $('#img').html(strImg);


        var imgNumDetail=0;
        var strImgDetail ='';
        if([[${goodsGoods.detailImgs}]]!=undefined && [[${goodsGoods.detailImgs}]]!=[]) {
            var detailImgs = [[${goodsGoods.detailImgs}]];
            var i = 0;
            for (o in detailImgs) {
                i++;
                imgNumDetail++;
                var c = "divImgDetail";
                strImgDetail  += '<div id="imgIdDetail'+imgNumDetail+'" class="'+c+'">' +
                    '<img  onclick="setImg(\'imgIdDetail'+imgNumDetail +'\')" src="'+detailImgs[o].imgurl+'" style="width:100px;height: 80px;margin-bottom: 1px;"><br>' +
                    '<i style="float: right;padding-top: 4px;" class="fa fa-close" onclick="delImg(\'imgIdDetail'+imgNumDetail +'\')"></i></div>';

            }
        }
        $('#img_detail').html(strImgDetail);


	</script>
	<script language="JavaScript" th:inline="javascript">
	/**
	 * 选择运费方式
	 */
	$("input[name=postSize]").click(function(){
	    var value = $(this).val();
	    if(value==0){
	    	$("#postFeeDiv").show();
	    }else{
	    	$("#postFeeDiv").hide();
	    	$("#postFee").val("");
	    }
	});

	$("input[name=category]").click(function(){
		var value = $(this).val();
		if(value==0){
			$("#spikeStrDiv").hide();
			$("#spikeEndDiv").hide();
		}else{
			$("#spikeStrDiv").show();
			$("#spikeEndDiv").show();

		}
	})
	</script>
</body>
</html>
